package com.reder.practice.controller;

import com.reder.practice.bean.Manager;
import com.reder.practice.bean.User;
import com.reder.practice.common.annotation.FromSession;
import com.reder.practice.common.dto.ServerResponse;
import com.reder.practice.common.enums.state.CommonState;
import com.reder.practice.common.filter.DebugFilter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * DEBUG 调试 API 层
 *
 * @author Fish
 * <p>Email: fishinlove@163.com</p>
 * <p>created by 2019/09/24 12:09:04</p>
 */
@RestController
@RequestMapping(path = "/debug")
public class DebugController {

    @RequestMapping(path = "/mode", method = RequestMethod.GET)
    public ServerResponse isDebugMode() {
        return ServerResponse.response(CommonState.SUCCESS, DebugFilter.isDebugMode());
    }

    @RequestMapping(path = "/on", method = RequestMethod.PUT)
    public ServerResponse turnOnDebugMode() {
        return ServerResponse.response(CommonState.SUCCESS, DebugFilter.turnOnDebugMode());
    }

    @RequestMapping(path = "/off", method = RequestMethod.PUT)
    public ServerResponse turnOffDebugMode() {
        return ServerResponse.response(CommonState.SUCCESS, DebugFilter.turnOffDebugMode());
    }

    @RequestMapping(path = "/currentUser", method = RequestMethod.GET)
    public ServerResponse isDebugMode(@FromSession User user) {
        return ServerResponse.response(CommonState.SUCCESS, user);
    }

    @RequestMapping(path = "/currentManager", method = RequestMethod.GET)
    public ServerResponse isDebugMode(@FromSession Manager manager) {
        return ServerResponse.response(CommonState.SUCCESS, manager);
    }
}
